#include<stdio.h>
typedef struct
{
int numitor;
int numarator;
}Rational;

Rational produs(Rational,Rational);
Rational suma(Rational,Rational);
Rational diff(Rational,Rational);
Rational q(Rational,Rational);
int cmmdc(int,int);
Rational simplifica (Rational);

int main()
{
Rational a,b;
a.numarator=1;
a.numitor=2;
b.numarator=1;
b.numitor=4;
Rational rezultatOperatie;
rezultatOperatie=produs(a,b);
printf("\n%d / %d\n",rezultatOperatie.numarator,rezultatOperatie.numitor);
return 0;
}

Rational produs(Rational a,Rational b)
{
Rational r;
r.numarator=a.numarator*b.numarator;
r.numitor=a.numitor*b.numitor;
return simplifica(r);
}

int cmmdc(int n,int m)
{
int r;
r=n%m;
while(r!=0)
{
n=m;
m=r;
r=n%m;
}
return m;
}

Rational simplifica (Rational p)
{
Rational r;
r.numarator=p.numarator/cmmdc(p.numarator,p.numitor);
r.numitor=p.numitor/cmmdc(p.numarator,p.numitor);
return r;
}

